package _thread_lock._AQS;

import java.util.concurrent.TimeUnit;

/**
 * @Author: huangya
 * @Date: 2021/10/11
 * @Description:
 */
public class HyAqsTest {

    public static void main(String[] args) {
        HyReentrantLock hyReentrantLock = new HyReentrantLock();
        new Thread(()->{
            hyReentrantLock.lock();
            try {
                TimeUnit.SECONDS.sleep(5000);
                System.out.println(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            hyReentrantLock.unlock();
        }).start();
        new Thread(()->{
            hyReentrantLock.lock();
            try {
                TimeUnit.SECONDS.sleep(5000);
                System.out.println(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            hyReentrantLock.unlock();
        }).start();
        new Thread(()->{
            hyReentrantLock.lock();
            try {
                TimeUnit.SECONDS.sleep(5000);
                System.out.println(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            hyReentrantLock.unlock();
        }).start();
    }
}
